﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using SQLExecute;

/// <summary>
/// Summary description for wsSearchProfiles
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class wsSearchProfiles : System.Web.Services.WebService {

    public wsSearchProfiles () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]
    public string[] Get_List_FullName(string prefixText)
    {
        //int count = 10;
        string sql = "select fullname from tbl_profiles where fullname like N'" + prefixText + "%'";

        //SqlDataReader r = SqlHelper.ExecuteReader(Common.strConnect, CommandType.Text, sql);
        DataSet ds = SqlHelper.ExecuteDataset(Common.strConnect, CommandType.Text, sql);

        string[] items = new string[ds.Tables[0].Rows.Count];
        int i = 0;

        foreach (DataRow r in ds.Tables[0].Rows)
        {
            items.SetValue(r["fullname"].ToString(), i);
            i++;

        }

        return items;
    }
}

